#ifndef WINDOWTOOLS_H
#define WINDOWTOOLS_H

class WindowTools;

#include "common.h"


class WindowTools : public CassiopeiaComponent
{
public:
	struct Size
	{
		int Width;
		int Height;
	};

	struct ReducedData
	{
		bool IsResizable;
		Size Size;
	};

	~WindowTools();
	CCState Activate();
	CCState Deactivate();

	static WindowTools* CreateInstance(HINSTANCE hInstance);

	void Add(HWND hWnd);
	void Remove(HWND hWnd);
	bool Exists(HWND);	
private:
	WindowTools(HINSTANCE hInstance);

	void RecoverWindowsInCaseOfPreviousCrash();
	void ResetReducedWindows();
	void ReduceWindowsExceptOne(HWND);
	bool RestoreReducedWindowInternal(HWND);
	void RestoreReducedWindow(HWND);
	void ReduceWindow(HWND);
	
	map<HWND, ReducedData> windowsForReducing;

	int menuHeight;
	int captionHeight;
	int frameHeight;
	int smallCaptionHeight;
	int minHeight;
	int minSmallHeight;

	HINSTANCE hInstance;
	HWINEVENTHOOK hWinEventHook;
	HHOOK hMouseHook;

	bool mouseHookActive;


	static WindowTools* instance;

	static VOID CALLBACK WinEventProc(HWINEVENTHOOK hWinEventHook, DWORD dwEvent, HWND hWnd, LONG idObject, LONG idChild, DWORD idEventThread, DWORD dwmsEventTime);
	static LRESULT CALLBACK MouseHookProc(int code, WPARAM wParam, LPARAM lParam);
	static BOOL CALLBACK EnumWindowsProc(HWND hWnd, LPARAM lParam);
};

#endif